package com.yesallchina.wxapp.officialaccount.api.enums;


import com.yesallchina.wxapp.officialaccount.api.beans.*;

public enum MessageEventTypeEnum {
    /**
     * 文本
     */
    TEXT("text", TextMessage.class),
    /**
     * 位置
     */
    LOCATION("location", LocationMessage.class),
    /**
     * 图片
     */
    IMAGE("image", ImageMessage.class),
    /**
     * 语音
     */
    VOICE("voice", VoiceMessage.class),
    /**
     * 事件
     */
    EVENT("event", EventMessage.class),
    /**
     * 视频
     */
    VIDEO("video", VideoMessage.class),
    /**
     * 文本+图片
     */
    NEWS("news", NewsMessage.class),
    /**
     * 音乐
     */
    MUSIC("music", MusicMessage.class);

    private String msgType;
    private Class clazz;

    MessageEventTypeEnum(String msgType, Class clazz) {
        this.msgType = msgType;
        this.clazz = clazz;
    }

    public String getMsgType() {
        return msgType;
    }

    public Class getClazz() {
        return clazz;
    }

    public static Class getClass(String msgType) {
        for (MessageEventTypeEnum type : MessageEventTypeEnum.values()) {
            if (type.getMsgType().equalsIgnoreCase(msgType)) {
                return type.getClazz();
            }
        }
        return Object.class;
    }

}
